
package com.cqeec.gams.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 错误控制器。

 */
@Controller
@RequestMapping("/error/")
public class ErrorController {
	@RequestMapping("/401.html")
	public ModelAndView goto401Page(HttpSession session) {
		ModelAndView mav = new ModelAndView("error/401");
		Object obj = session.getAttribute("account");
		if (obj == null) {
			mav.addObject("pageName", "登录页面");
			mav.addObject("page", "login.html");
		} else {
			mav.addObject("pageName", "主页面");
			mav.addObject("page", "app/main.html");
		}
		return mav;
	}

	@RequestMapping("/404.html")
	public ModelAndView goto404Page(HttpSession session) {
		ModelAndView mav = new ModelAndView("error/404");
		Object obj = session.getAttribute("account");
		if (obj == null) {
			mav.addObject("pageName", "登录页面");
			mav.addObject("page", "login.html");
		} else {
			mav.addObject("pageName", "主页面");
			mav.addObject("page", "app/main.html");
		}
		return mav;
	}

	@RequestMapping("/error.html")
	public ModelAndView gotoErrorPage(HttpSession session) {
		ModelAndView mav = new ModelAndView("error/error");
		Object obj = session.getAttribute("account");
		if (obj == null) {
			mav.addObject("pageName", "登录页面");
			mav.addObject("page", "login.html");
		} else {
			mav.addObject("pageName", "主页面");
			mav.addObject("page", "app/main.html");
		}
		return mav;
	}
}
